#pragma once

class TerrainMesh
{
public:
	TerrainMesh(ChunkSystem::TerrainBlockChunkItem* pTerrainBlock);
	virtual ~TerrainMesh(void);

	//IRenderable
	virtual void Load( ChunkSystem::IRenderer* pRenderer );
	virtual void Unload( void );
	virtual void Draw( ChunkSystem::IRenderer* pRenderer );

	//loading listener
	virtual void OnProgressIntervalNotify( uint16 uPercentage );

private:

	bool _BuildTerrain( LPDIRECT3DDEVICE9 pDevice );
	bool _DrawTerrain( LPDIRECT3DDEVICE9 pDevice );

private:

	bool					m_bBuiltFlag;
	ChunkSystem::TerrainBlockChunkItem*		m_pTerrainBlock;

	bool					m_bShowAABB;
	bool					m_bShowHull;

	LPDIRECT3DVERTEXBUFFER9 m_pVB;
	LPDIRECT3DINDEXBUFFER9  m_pIB;

	CRITICAL_SECTION m_CriticalSection;
};

